package com.ccsoft.atools.controller;


import com.ccsoft.atools.model.SysRolep;
import com.ccsoft.atools.service.SysRolepService;
import com.ccsoft.atools.utils.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("/sysRolep")
public class SysRolepController {

    @Autowired
    private SysRolepService service;

    @DeleteMapping("/deleteByPrimaryKey/{iid}")
    public JsonResult deleteByPrimaryKey(@PathVariable java.lang.Integer iid) {
        return JsonResult.ok(service.deleteByPrimaryKey(iid));
    }

    @GetMapping("/selectByPrimaryKey/{iid}")
    public JsonResult selectByPrimaryKey(@PathVariable java.lang.Integer iid) {
        return JsonResult.ok(service.selectByPrimaryKey(iid));
    }

    @GetMapping("/selectAll")
    public JsonResult selectAll() {
        return JsonResult.ok(service.selectAll());
    }

    @PostMapping("/insert")
    public JsonResult insert(@RequestBody SysRolep record) {
        return JsonResult.ok(service.insertSelective(record));
    }

    @PutMapping("/update")
    public JsonResult update(@RequestBody SysRolep record) {
        System.out.println("控制器接受到的参数是：" + record.toString());
        return JsonResult.ok(service.updateByPrimaryKey(record));
    }

    @GetMapping("/selectByRoleIid/{roleIid}")
    public JsonResult selectByRoleIid(@PathVariable int roleIid) {
        return JsonResult.ok(service.selectByRoleIid(roleIid));
    }

    @GetMapping("/getAllPermissions")
    public JsonResult getAllPermissions() {
        return JsonResult.ok(service.getAllPermissions());
    }
}